package com.ruoyi.common.enums;

import cn.hutool.core.util.NumberUtil;
import lombok.AllArgsConstructor;
import lombok.Getter;
import org.apache.commons.lang3.EnumUtils;

import java.util.*;

/**
 * 登录相应枚举类
 */
@AllArgsConstructor
@Getter
public enum LoginStatus {

    /** */
    SUCCESS(200,"登录成功"),
    FAIL(500,"信息不存在，请联系相关管理人员"),
    UUID_PAST_DUE(500,"登录信息不存在或已过期，请重新登录"),
    WECHAT_NOT_HAS(201,"请确认上岗证和姓名"),
    USER_NOT_HAS(202,"用户信息不存在，请输入上岗证、姓名"),
    USER_PHONE_AIL(203,"该上岗证已有绑定用户，是否绑定当前微信手机号"),
    SUCCESS_SMS(204,"发送成功"),
    USER_NOT_POSTSNUMBER(205,"用户没有上岗证，走默认注册流程");

    private final Integer code;
    private final String msg;

    /**
     * 类加载时初始化
     */
    private final static Set<Integer> CODES = new HashSet<Integer>(){{
        List<LoginStatus> enumMap = EnumUtils.getEnumList(LoginStatus.class);
        for (LoginStatus loginStatus : enumMap) {
            add(loginStatus.getCode());
        }
    }};
    /**
     * 判断code码是否是该枚举类的
     */
    public static Boolean isCode(String code){
        return NumberUtil.isNumber(code) && CODES.contains(Integer.valueOf(code));
    }

}









